﻿using System;
using System.Net;

namespace SyncDBServer
{
    public static class Utils
    {
        /// <summary>
        /// Convert string network info (format: "xxx.xxx.xxx.xxx:yyy")to IPEndPoint class
        /// </summary>
        /// <param name="EndPoint"></param>
        public static IPEndPoint MakeIPEndPoint(string EndPoint)
        {
            string[] parts = EndPoint.Split(new char[]{':'}, StringSplitOptions.RemoveEmptyEntries);
            try
            {
                IPAddress addr = IPAddress.Parse(parts[0]);
                int port = Int32.Parse(parts[1]);
                return new IPEndPoint(addr, port);
            }
            catch
            {
                return null;
            }
        }
    }
}
